package com.suning.sawp.member.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.suning.sawp.member.dao.LabelDao;
import com.suning.sawp.member.dto.Label;
import com.suning.sawp.member.dto.MemLabelRel;
import com.suning.sawp.member.vo.CustLabelVo;
import com.suning.sawp.member.vo.LabelVo;

/**
 * 
 * 标签dao实现<br>
 *
 * @author 14060886 祝翔龙
 */
@Repository
public class LabelDaoImpl extends BaseDaoImpl implements LabelDao {

	@Override
	public List<LabelVo> selectLabelList(Map<String, Object> params) {
		return dalClientRead.queryForList("label.selectLabelList", params, LabelVo.class);
	}

	@Override
	public Integer countLabelList(Map<String, Object> params) {
		return dalClient.queryForObject("label.countLabelList", params, Integer.class);
	}

	@Override
	public LabelVo selectLabelInfo(Map<String, Object> params) {
		return dalClient.queryForObject("label.selectLabelInfo", params, LabelVo.class);
	}

	@Override
	public void saveLabel(Label label) {
		super.save(label);
	}

	@Override
	public void batchSaveLabel(List<Label> labelList) {
		super.batchSave("label.insertLabel", labelList);
	}

	@Override
	public void deleteLabelById(Map<String, Object> params) {
		dalClient.execute("label.deleteLabelById", params);
	}

	@Override
	public void deleteLabelByParentId(Map<String, Object> params) {
		dalClient.execute("label.deleteLabelByParentId", params);
	}

	@Override
	public List<LabelVo> selectSubLabelList(Map<String, Object> params) {
		return dalClientRead.queryForList("label.selectSubLabelList", params, LabelVo.class);
	}

	@Override
	public void updateLabel(Label label) {
		super.update(label);
	}

	@Override
	public List<Label> queryAllLabel(String channelCode) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("channelCode", channelCode);
		return dalClientRead.queryForList("label.queryAllLabel", paramMap, Label.class);
	}

	@Override
	public List<MemLabelRel> queryMemberLabelInfo(String custNo) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("custNo", custNo);
		return dalClientRead.queryForList("label.queryMemberLabelInfo", paramMap, MemLabelRel.class);
	}

	@Override
	public List<CustLabelVo> selectLabelByCust(String custId) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("custId", custId);
		return dalClientRead.queryForList("label.selectLabelByCust", paramMap, CustLabelVo.class);
	}

	public void delMemLabelRelByCustId(Long custId) {
		if (custId == null) {
			return;
		}
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("custId", custId);
		dalClient.execute("label.delMemLabelRelByCustId", paramMap);
	}

	public boolean batchSaveMemLabelRel(List<MemLabelRel> list) {
		return super.batchSave("label.batchSaveMemLabelRel", list);
	}

	public List<CustLabelVo> queryFiveLabelByCustId(Long custId) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("custId", custId);
		return dalClient.queryForList("label.queryFiveLabelByCustId", paramMap, CustLabelVo.class);
	}

}
